package org.quipu.client;

import org.quipu.client.events.AppEventProducer;
import org.quipu.client.events.AppEvent;
import org.quipu.client.events.AppEventBus;

public class ReloadCallback extends AppEventProducer {

    private final AppEvent event;
    private int counter;

    public ReloadCallback(AppEventBus eventBus, AppEvent event, int counter) {
        super(eventBus);
        this.event = event;
        this.counter = counter;
    }

    public void call() {
        counter--;
        if(counter <= 0) {
            getEventBus().fireEvent(event);
        }
    }
}
